package com.chixing.day02_switch_case.test;

import java.nio.charset.StandardCharsets;
import java.util.*;

public class Work1 {
    /**
     * **1. 在10个元素的数组中找出只出现一次的元素**
     *
     * @param args
     */
    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 3, 5, 6, 7, 4, 1};
        //1.将数组转换为字符串
        String str = "";
        for (int i = 0; i < array.length; i++) {
            str += array[i];
        }
        //2.创建新数组接收
        int[] newArray=new int[array.length];
        int size=0;

        for (int i = 0; i < str.length(); i++) {
            if (str.indexOf(str.charAt(i))==str.lastIndexOf(str.charAt(i)))
                newArray[size++]=Integer.parseInt(String.valueOf(str.charAt(i)));
        }

        for (int i = 0; i < size; i++) {
            System.out.println(newArray[i]);
        }
    }
}

